****************************************
**PAPER: religion and voting behaviour**
**AUTHOR: Piacentini, Molteni, Maraffi**
****************************************


global data //[insert path here]
global cleaned //[insert path here]
global output  //[insert path here]
global wd //[insert path here]


**RETRIEVING VARIABLE ABOUT ANTI-IMMIGRATION ATTITUDES FROM PRE-ELECTION SURVEY**
use "$data\Itanes2022_PRE_CORE_Itanes_release 02_weighted", clear
rename D03_3 immigrazione
keep seriale immigrazione
save "$wd\IMM", replace


use "$data\Itanes2022_POST_release 02_weighted", clear
merge 1:1 seriale  using "$wd\IMM"
drop if _merge==2

*****TYPOLOGY*****

recode D10 (1=1 "Catholic")(6 7=2 "Not religious")(2 3 4 5 8 99=.), gen(denomination_R)
recode D11 (1=1 "Never")(2 3=2 "Occasionally")(4/6=3 "At least monthly")(98 99=.), gen(attendance_R)
recode D11 (1=1 "Never")(2 3=2 "Occasionally")(4=3 "At least monthly")(5=4 "2/3 times a month")(6=5 "Weekly or more often") (98 99=.), gen(attendance_RR)

gen tipology=.
replace tipology=1 if denomination_R==1 & attendance_R==3
replace tipology=2 if denomination_R==1 & inlist(attendance_R, 1, 2)
replace tipology=3 if denomination_R==2 & inlist(attendance_R, 1, 2)

lab def tipologia 1"Practicing Catholic" 2"Not-practicing Catholic" 3"Not religious" 
lab val tipology tipologia 

gen tipology2=.
replace tipology2=1 if denomination_R==1 & attendance_RR==5
replace tipology2=2 if denomination_R==1 & attendance_RR==4
replace tipology2=3 if denomination_R==1 & attendance_RR==3
replace tipology2=4 if denomination_R==1 & inlist(attendance_RR,1, 2)
replace tipology2=5 if denomination_R==2 & inlist(attendance_RR,1, 2)

lab def tipologia2 1"Weekly Practicing Catholic" 2"Monthly/weekly practicing Catholic" 3"Monthly Practicing Catholic" 4"Not-practicing Catholic" 5"Not religious" 
lab val tipology2 tipologia2 


**CONTROL VARIABLES**

recode scol (1/2=1 "Primary") (3/5=2 "Secondary") (6/11=3 "Tertiary"), gen(edu) label(edu)
recode D01 (1=1 "Male") (2=2 "Female") (3/99=.), gen(gender)
recode D09 (98/99=.), gen(income)
recode Q10LHb (1=1 "FdI") (2=2 "Lega") (3=3 "FI") (4=4 "Azione+IV") ///
(5=5 "M5S") (6=6 "PD") (7/99=.), gen(vote6)
recode Q10LHb (1 2 3 8 11=1 "DX/CDX")(4 5 6 7 9 10 12=0 "Other") (else=.),gen(voteCDX)
recode Q10LHb (1 2 8 =1 "DX/CDX")(3 4 5 6 7 9 10 11 12=0 "Other") (else=.),gen(voteCDX_noFI)

recode regione (1/7=1 "North") (8/11=2 "Red regions") (12/14=3 "Center") (15/20=4 "South/Islands"), gen(Area_Geo)	//Reds are Emilia, Toscana, Umbria, Marche
rename eta_classe age

**VARIABLES ABOUT ATTITUDES**

gen abortoOK=inlist(ITA01_03,1,2)
replace abortoOK=. if ITA01_03==98

gen omoOK=inlist(ITA01_05,3,4)
replace omoOK=. if ITA01_05==98

gen immOK=inlist(immigrazione,4,5,6,7)
replace immOK=. if immigrazione==98

gen abortoNO=inlist(ITA01_03,3,4)
replace abortoNO=. if ITA01_03==98

gen omoNO=inlist(ITA01_05,1,2)
replace omoNO=. if ITA01_05==98

gen immNO=inlist(immigrazione,1,2,3)
replace immNO=. if immigrazione==98



**CLEANING AND SAVING**

keep denomination_R attendance_R attendance_RR tipology tipology2 edu gender income vote6 voteCDX Area_Geo age abortoOK omoOK immOK abortoNO omoNO immNO voteCDX_noFI
save "$cleaned\ITANES_cleaned", replace
